package drinkkiosk;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 * This class loads from the settings file
 * @author Charles Ritchea
 */
public class Settings{
	/** */
	private static FileOutputStream fOut;
	/** */
	private static FileInputStream fIn;
	/** */
    private static DataInputStream dIn;
    private static BufferedReader br;
    private static InputStreamReader iSR;
    private static String kioskServerPort;
    private static String kioskClientPort;
    private static String bartenderHostname;
    private static String serialPort;
    private static String keyCode;

    /**
     * 
     * @return
     */
    public static String getBartenderHostname() {
        return bartenderHostname;
    }

    /**
     * 
     * @return
     */
    public static String getKeyCode() {
        return keyCode;
    }

    /**
     * 
     * @return
     */
    public static String getKioskClientPort() {
        return kioskClientPort;
    }

    /**
     * 
     * @return
     */
    public static String getKioskServerPort() {
        return kioskServerPort;
    }

    /**
     * 
     * @return
     */
    public static String getSerialPort() {
        return serialPort;
    }
	/**
	 * 
	 */
	public static void loadSettings(){
		try {
			fIn = new FileInputStream("drinkkiosk.ini");
                        dIn = new DataInputStream(fIn);
                        iSR = new InputStreamReader(dIn);
                        br = new BufferedReader(iSR);
                        String strLine;
                        for(int i = 0; (strLine = br.readLine()) != null; i++){
                            switch(i){
                                case 1:
                                    kioskServerPort = strLine;
                                    System.out.println(kioskServerPort);
                                    break;
                                case 3:
                                    kioskClientPort = strLine;
                                    System.out.println(kioskClientPort);
                                    break;
                                case 5:
                                    bartenderHostname = strLine;
                                    System.out.println(bartenderHostname);
                                    break;
                                case 7:
                                    serialPort = strLine;
                                    System.out.println(serialPort);
                                    break;
                                case 9:
                                    keyCode = strLine;
                                    System.out.println(keyCode);
                                    break;
                            }
                        }
			iSR.close();
		} catch (IOException ex) {
			Logger.getLogger(Settings.class.getName()).log(Level.SEVERE, null, ex);
		} 
	}
}